package com.shuai.jit.controller;



import com.shuai.jit.entity.R;
import com.shuai.jit.entity.course.Comment;
import com.shuai.jit.service.impl.CommentServiceImpl;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api("评论控制类")
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    CommentServiceImpl commentService;

    @RequestMapping("selectById")
    public R selectById(String id) {
        return R.ok().data("comment", commentService.selectComment(id));
    }

    @RequestMapping("/addComment")
    public R addComment(@RequestBody Comment comment) {
        Integer result = commentService.addComment(comment);
        if (result > 0) {
            return R.ok().data("article", "添加评论成功");
        } else {
            return R.error().data("article", "添加评论失败");
        }
    }
}
